package com.service;
import com.alibaba.fastjson.JSON;
import com.dao.HatProvinceDao;
import com.entity.HatProvince;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;

@Service
public class HatProvinceService
{
    @Resource
    private HatProvinceDao hatProvinceDao;

    //返回所有省份的json格式字符串
    public String returnProvinceComboBoxJsonStr()
    {
        ArrayList<HatProvince> provinceList = hatProvinceDao.getAllProvince();
        String jsonStr = JSON.toJSONString( provinceList );
        System.out.println( jsonStr );

        return jsonStr;
    }

    //根据id查询省份名
    public String returnProvinceNameById( Integer id )
    {
        HatProvince hatProvince = hatProvinceDao.getProvinceById( id );

        return hatProvince.getProvince();
    }


}
